package com.tadpole.music.view.activity.web;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.webkit.JavascriptInterface;

import com.tadpole.music.utils.ScreenshotUtil;
import com.tadpole.music.utils.SpUtil;
import com.tadpole.music.utils.ToastUtils;
import com.tadpole.music.view.activity.login.LoginActivity;

/**
 * Created By 孙岩
 * on 2020/12/3
 */
public class H5DaiLi extends Object {
    private Activity activity;

    public H5DaiLi(Activity activity) {
        this.activity = activity;
    }

    @JavascriptInterface
    public void show401(){
        Intent intent = new Intent(activity, LoginActivity.class);
        activity.startActivity(intent);
    }

    /**
     * 截图
     */
    @JavascriptInterface
    public void screenshot() {
        ScreenshotUtil.saveScreenshotFromActivity(activity);
    }

    /**
     * 获取是否截图
     *
     * @return true 已截图 false 未截图
     */
    @JavascriptInterface
    public boolean getScreenshot() {
        return ScreenshotUtil.isPath();
    }

    /**
     * 获取是否截图
     */
    @JavascriptInterface
    public void  showPop(String a) {
        ToastUtils.show(a);
    }
}
